package com.atguigu.eduservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.eduservice.entity.subject.OneSubject;
import com.atguigu.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author hjt
 * @since 2021-04-09
 */
@Api("课程分类管理")
@RestController
@CrossOrigin
@RequestMapping("/eduService/eduSubject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService eduSubjectService;

    /**
     * 添加课程分类
     *
     * @return
     */
    @PostMapping("/addSubject")
    public R addSubject(MultipartFile file) {

        eduSubjectService.importSubjectData(file, eduSubjectService);
        return R.ok();
    }

    /**
     * 课程分类的列表功能
     *
     * @return
     */
    @GetMapping("/subject/list")
    public R subjectList() {
        List<OneSubject> list = eduSubjectService.findSubjectList();
        return R.ok().data("list", list);
    }

}

